<?php

// this is part of my experiement/example for doing JOINs with entities and Doctrine.

// refer to link at http://hellounderscoreworld.blogspot.com/2012/04/doctrine-joins.html

// uses entities ORM\Testing\Firstnames and ORM\Testing\Lastnames and corresponding sql tables

class Test_namejoins extends CI_Controller {

	public function __construct() {
            parent::__construct(); 

	}
        
        public function index() {

		$whichFamily = '2';

		$query = $this -> doctrine -> em -> createQuery ("SELECT a.firstname, b.lastname FROM ORM\Testing\Firstnames a JOIN a.mylastname b WHERE b.id = $whichFamily");

		$result = $query->getResult();
             //print_r($result);
		\Doctrine\Common\Util\Debug::dump($result);

		foreach ($result as $val1 => $val2) {
		//echo $val2;
			foreach ($val2 as $val3 => $val4) {
				echo $val4;
				echo " ";
				//echo firstname + " " + lastname;

			}
			echo "</br>";

		}

/*
		foreach ($result as $val => $val2) {
	//print_r($val2);
	//echo $val2;



		foreach ($val2 as $col => $val3) {
			//print_r($val3);
			//echo ($val3);
			$data = $val3;
			if ($col === 'fromUser') {
			echo "</br>My data is " . $data;
			}
		}
*/



	}
}